﻿using System;
using System.Reflection;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using TransactionServer.General_Classes;

namespace TransactionServer.ActivityDesign
{
    /// <summary>
    /// Interaction logic for EditFilter.xaml
    /// </summary>
    public partial class EditFilter : Page
    {
        CCondition item;

        public EditFilter(ref CCondition item)
        {
            this.item = item;
            InitializeComponent();

          /*  PropertyInfo[] properties = typeof(ConditionOperator).GetProperties(BindingFlags.Public | BindingFlags.Static);

            foreach (PropertyInfo prop in properties)
            {
                operatorBox.Items.Add(prop.GetConstantValue());
            }*/

            operatorBox.Items.Add(ConditionOperator.Equal);
            operatorBox.Items.Add(ConditionOperator.Less);
            operatorBox.Items.Add(ConditionOperator.LessEqual);
            operatorBox.Items.Add(ConditionOperator.More);
            operatorBox.Items.Add(ConditionOperator.MoreEqual);
            operatorBox.Items.Add(ConditionOperator.NotEqual);


            attributeText.Text = item.attribute;
            operatorBox.SelectedIndex = operatorBox.Items.IndexOf(item.opr);
            valueText.Text = item.value;
        }

        private void attributeText_TextChanged(object sender, TextChangedEventArgs e)
        {
            item.attribute = attributeText.Text;
        }

        private void operatorBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (operatorBox.SelectedValue != null)
            {
                item.opr = (string)operatorBox.SelectedValue; 
            }
        }

        private void valueText_TextChanged(object sender, TextChangedEventArgs e)
        {
            item.value = valueText.Text;
        }
    }
}
